home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mc302emb.zip / CFLEA.DOC < prev    next >
Text File  |  1994-03-18  |  6KB  |  139 lines

  1. C-FLEA VIRTUAL MACHINE OVERVIEW:
  2.  
  3.   4 Registers:
  4.     ACC     - 16 bit accumulator 8 bit accesses are auto zero-filled
  5.     INDEX   - 16 bit addressing register, cannot be manipulated as 8 bits
  6.     SP      - 16 bit stack pointer
  7.     PC      - 16 bit program counter
  8.  
  9.   ACC always contains 16 valid bits. All operations are performed in 16
  10.   bit precision. 8 bit operands are zero-filled when they are fetched.
  11.  
  12.   SP decrements when data is pushed, and always points to the last
  13.   entry which was pushed (ie: 0,S gives data on "top" of stack).
  14.  
  15.   Data is stored in LITTLE ENDIAN format. Ie: LOW BYTE is FIRST. This
  16.   allows us to use the same address to refer to an 8 bit or a 16 bit
  17.   quantity.
  18.  
  19.   There are no user accessable flags. In the case of CMP, internal flags
  20.   are maintained only long enough to accomodate the LT-UGE instructions.
  21.  
  22.   This instruction set and associated mnemonics are:
  23.   Copyright 1994 Dave Dunfield
  24.   All rights reserved.
  25.  
  26. GENERAL ADDRESSING MODES
  27.  Syntax   Description
  28.  ---------------------------------------------------
  29.   #n      Immediate (8 or 16 bit operand)
  30.   aaaa    Direct memory address
  31.   I       Indirect (through INDEX register) no offset
  32.   n,I     Indirect (through INDEX register) with 8 bit offset
  33.   n,S     Indirect (through SP) with 8 bit offset
  34.   S+      On Top of Stack (remove)
  35.   [S+]    Indirect through TOS (remove)
  36.   [S]     Indirect through TOS (leave on stack)
  37.  NOTES:
  38.   Mode S+ always pops 16 bits from stack. Only 16 bit values can be pushed.
  39.   Modes [S+] and [S] will always use a 16 bit address on the top of the
  40.   stack, but the final target can be 8 or 16 bits. (Depending on inst.)
  41.  
  42. MEMORY ADDRESSING INSTRUCTIONS: (Use addressing modes above)
  43.  Name     Description                          (Unused address modes)
  44.  --------------------------------------------------------------------
  45.   LD      Load ACC 16 bits
  46.   LDB     Load ACC 8 bits
  47.   ADD     Add 16 bits
  48.   ADDB    Add 8 bits
  49.   SUB     Subtract 16 bits
  50.   SUBB    Subtract 8 bits
  51.   MUL     Multiply 16 bits
  52.   MULB    Multiply 8 bits
  53.   DIV     Divide 16 bits
  54.   DIVB    Divide 8 bits
  55.   AND     And 16 bits
  56.   ANDB    And 8 bits
  57.   OR      Or 16 bits
  58.   ORB     Or 8 bits
  59.   XOR     Xor 16 bits
  60.   XORB    Xor 8 bits
  61.   CMP     Compare 16 bits (ACC=1 if equal)
  62.   CMPB    Compare 8 bits
  63.   LDI     Load INDEX (16 bits only)
  64.   LEAI    Load INDEX with address              (00, 05)
  65.   ST      Store ACC 16 bits                    (00, 05)
  66.   STB     Store ACC 8 bits                     (00, 05)
  67.   STI     Store INDEX (16 bits only)           (00, 05)
  68.   SHR     Shift right (8 bit count only)
  69.   SHL     Shift left  (8 bit count only)
  70.  
  71. COMPARE MODIFIER INSTRUCTIONS:
  72.  Name     Description
  73.  ----------------------------------------------------------------------
  74.   LT      ACC = 1 if less than             (signed)
  75.   LE      ACC = 1 if less than or equal    (signed)
  76.   GT      ACC = 1 if greater than          (signed)
  77.   GE      ACC = 1 if greater than of equal (signed)
  78.   ULT     ACC = 1 if lower than            (unsigned)
  79.   ULE     ACC = 1 if lower than or same    (unsigned)
  80.   UGT     ACC = 1 if higher than           (unsigned)
  81.   UGE     ACC = 1 if higher than or same   (unsigned)
  82.  NOTES:
  83.   NOT instruction is used to implement explicit NE.
  84.   These instructions must IMMEDIATELY follow a CMP instruction! One of
  85.   PUSHA/TAI/JMP/SJMP/JZ/SJZ/JNZ/SJNZ may occur between the CMP and the
  86.   above instructions, but any other instruction may cause the result of
  87.   the CMP to be lost!
  88.  
  89. JUMP INSTRUCTIONS:
  90.  Name     Description
  91.  ----------------------------------------------------------------------
  92.   JMP     Long jump (16 bit absolute)
  93.   JZ      Long jump if ACC=0 (16 bit absolute)
  94.   JNZ     Long jump if ACC!=0 (16 bit absolute)
  95.   SJMP    Short jump (8 bit PC offset)
  96.   SJZ     Short jump if ACC=0 (8 bit PC offset)
  97.   SJNZ    Short jump if ACC!=0 (8 bit PC offset)
  98.   IJMP    Indirect jump (Address in ACC)
  99.   SWITCH  Jump through switch table (ACC=value, INDEX=table)
  100.  NOTES:
  101.   Switch table format: addr1, value1, addr2, value2, ... 0, defaultaddr
  102.  
  103. STACK MANIPULATION INSTRUCTIONS:
  104.  Name     Description
  105.  ----------------------------------------------------------------------
  106.   CALL    Call subroutine (16 bit absolute address)
  107.   RET     Return from subroutine
  108.   ALLOC   Allocate space on stack (8 bit value)
  109.   FREE    Release space on stack (8 bit value)
  110.   PUSHA   Push ACC on stack
  111.   PUSHI   Push INDEX on stack
  112.   TAS     Copy ACC to SP
  113.   TSA     Copy SP to ACC
  114.  NOTES:
  115.   Explicit PULL instructions are not required since various addressing
  116.   modes use (and remove) the top item on the stack (PULLA = LD S+).
  117.  
  118. MISC INSTRUCTIONS:
  119.  Name    Description
  120.  ----------------------------------------------------------------------
  121.   CLR    Zero ACC
  122.   COM    Complement ACC (ACC = ACC XOR FFFF)
  123.   NEG    Negate ACC (ACC = 0 - ACC)
  124.   NOT    ACC = 1 if ACC was 0, else ACC = 0
  125.   INC    Increment ACC
  126.   DEC    Decrement ACC
  127.   TAI    Copy ACC to INDEX
  128.   TIA    Copy INDEX to ACC
  129.   ADAI   Add ACC to INDEX
  130.   ALT    Get alternate result from MUL/DIV
  131.   OUT    Output byte in ACC to PORT
  132.   IN     Read byte from PORT
  133.  NOTES:
  134.   ALT obtains the remainder after DIV, and in some implementations,
  135.   also obtains the high word after a multiply. This instruction must
  136.   be executed IMMEDIATELY after the MUL or DIV. A PUSHA or TAI inst.
  137.   is allowed between the MUL/DIV (In case you want to save both results),
  138.   but any other instruction may cause the alternate result to be lost!
  139.